<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<#include "/include/head_common.ftl">
	<#include "/include/login_trace.ftl">
	<#assign permissionSet = fm.getPermission() />
	<#assign edit= fm.hasPermission("sql:datasource:edit",permissionSet)/>
	<#assign view= fm.hasPermission("sql:datasource:view",permissionSet)/>
	<#assign disabled = edit?string('','disabled')/>
	<#assign driverMap={"请选择","","MYSQL","com.mysql.cj.jdbc.Driver","ORACLE":"oracle.jdbc.driver.OracleDriver",
		"DB2":"com.ibm.db2.jcc.DB2Driver","SQLSERVER":"com.microsoft.sqlserver.jdbc.SQLServerDriver"}/>
<title>
	<#if edit>
		数据源<#if datasource.id??>修改<#else>添加</#if>
	<#else>
		数据源查看
	</#if>
</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(
			function() {
				closeTip();
				$("#value").focus();
				$("#inputForm")
						.validate(
								{
									submitHandler : function(form) {
										loading('正在提交，请稍等...');
										form.submit();
									},
									errorContainer : "#messageBox",
									errorPlacement : function(error, element) {
										$("#messageBox").text("输入有误，请先更正。");
										if (element.is(":checkbox")
												|| element.is(":radio")
												|| element.parent().is(
														".input-append")) {
											error.appendTo(element.parent()
													.parent());
										} else {
											error.insertAfter(element);
										}
									}
								});
			});
	function goback(){
    	$.cookie('goback','goback',{path: '/',expires: 1});
    	history.go(-1);
    }

</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<#if view >
			<li><a href="${rootUrl}/sql/dataSource/list">数据源列表</a></li>
		</#if>
		<li class="active">
			<a href="${rootUrl}/sql/dataSource/edit?id=${datasource.id!''}">
				<#if edit>
					数据源<#if datasource.id??>修改<#else>添加</#if>
				<#else>
					数据源查看
				</#if>
			</a>
		</li>
	</ul>
	<br />
	<form id="inputForm" action="${rootUrl}/sql/dataSource/edit" method="post"
		class="form-horizontal form-signin">
		<input type="hidden" name="id" value="${datasource.id!''}" />
		<script type="text/javascript">top.$.jBox.closeTip();</script>
		<div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<input id="value" name="name" value="${datasource.name!''}" maxlength="50"
					class="required"  type="text" <#if !edit || datasource.id ??> disabled </#if>/>
				<span class="help-inline"><font color="red">* 初始化后不能修改</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">驱动:</label>
			<div class="controls">
				<select id="driverClassName" name="driverClassName" class="required input-large" <#if !edit || datasource.id ??> disabled </#if> >
					<#list driverMap?keys as key>
						<option value="${driverMap[key]}"  <#if datasource.driverClassName?? && datasource.driverClassName = driverMap[key]> selected </#if> >${key}</option>
					</#list>
				</select>
                <span class="help-inline"><font color="red">* 初始化后不能修改</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">连接URL:</label>
			<div class="controls">
				<textarea name="url" class="input-xxlarge" style="height: 23px; width: 800px;" ${disabled}>${datasource.url!''}</textarea>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">用户名:</label>
			<div class="controls">
				<input name="username" value="${datasource.username!''}" maxlength="200"
					   class="required"  type="text" ${disabled}/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">密&nbsp;&nbsp;码:</label>
			<div class="controls">
				<input name="password" value="${datasource.password!''}" maxlength="200"
					   class="required"  type="password" ${disabled}/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">初始大小:</label>
			<div class="controls">
				<input name="sort" value="${datasource.initialSize!''}" maxlength="11"
					class="required digits"  type="text" ${disabled}/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">最大连接:</label>
			<div class="controls">
				<input name="maxActive" value="${datasource.maxActive!''}" maxlength="11"
					   class="required digits"  type="text" ${disabled}/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">最小空闲:</label>
			<div class="controls">
				<input name="minIdle" value="${datasource.minIdle!''}" maxlength="11"
					   class="required digits"  type="text" ${disabled}/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">最大空闲:</label>
			<div class="controls">
				<input name="maxIdle" value="${datasource.maxIdle!''}" maxlength="11"
					   class="required digits"  type="text" ${disabled}/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">最大等待时间:</label>
			<div class="controls">
				<input id = "maxWait" name="maxWait" value="${datasource.maxWait!''}" maxlength="11"
					   class="required digits"  type="text" ${disabled}/>
				<span class="help-inline"><font color="red">单位毫秒</font> </span>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">保持连接:</label>
			<div class="controls">
				<#if datasource.keepAlive??>
					<label><input ${disabled} name="keepAlive" type="radio" value="true"<#if datasource.keepAlive>checked="checked"</#if> />是</label>
					<label><input ${disabled} name="keepAlive" type="radio" value="false"<#if !datasource.keepAlive>checked="checked"</#if> />否</label>
				<#else>
					<label><input ${disabled} name="keepAlive" type="radio" value="true" checked="checked" />是</label>
					<label><input ${disabled} name="keepAlive" type="radio" value="false"/>否</label>
				</#if>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">空闲测试:</label>
			<div class="controls">
				<#if datasource.testWhileIdle??>
					<label><input ${disabled} name="testWhileIdle" type="radio" value="true"<#if datasource.testWhileIdle>checked="checked"</#if> />是</label>
					<label><input ${disabled} name="testWhileIdle" type="radio" value="false"<#if !datasource.testWhileIdle>checked="checked"</#if> />否</label>
				<#else>
					<label><input ${disabled} name="testWhileIdle" type="radio" value="true" checked="checked" />是</label>
					<label><input ${disabled} name="testWhileIdle" type="radio" value="false"/>否</label>
				</#if>
			</div>
		</div>

		<<div class="control-group">
			<label class="control-label">校验SQL:</label>
			<div class="controls">
				<input name="validationQuery" value="${datasource.validationQuery!''}" maxlength="200"
					   class="required"  type="text" ${disabled}/>
				<span class="help-inline"><font color="red">校验连接是否可用的SQL</font> </span>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">获取校验:</label>
			<div class="controls">
				<#if datasource.testOnBorrow??>
					<label><input ${disabled} name="testOnBorrow" type="radio" value="true"<#if datasource.testOnBorrow>checked="checked"</#if> />是</label>
					<label><input ${disabled} name="testOnBorrow" type="radio" value="false"<#if !datasource.testOnBorrow>checked="checked"</#if> />否</label>
				<#else>
					<label><input ${disabled} name="testOnBorrow" type="radio" value="true" checked="checked" />是</label>
					<label><input ${disabled} name="testOnBorrow" type="radio" value="false"/>否</label>
				</#if>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">归还校验:</label>
			<div class="controls">
				<#if datasource.testOnReturn??>
					<label><input ${disabled} name="testOnReturn" type="radio" value="true"<#if datasource.testOnReturn>checked="checked"</#if> />是</label>
					<label><input ${disabled} name="testOnReturn" type="radio" value="false"<#if !datasource.testOnReturn>checked="checked"</#if> />否</label>
				<#else>
					<label><input ${disabled} name="testOnReturn" type="radio" value="true" checked="checked" />是</label>
					<label><input ${disabled} name="testOnReturn" type="radio" value="false"/>否</label>
				</#if>
			</div>
		</div>


		<div class="control-group">
			<label class="control-label">缓存Statements:</label>
			<div class="controls">
				<#if datasource.poolPreparedStatements??>
					<label><input ${disabled} name="poolPreparedStatements" type="radio" value="true"<#if datasource.poolPreparedStatements>checked="checked"</#if> />是</label>
					<label><input ${disabled} name="poolPreparedStatements" type="radio" value="false"<#if !datasource.poolPreparedStatements>checked="checked"</#if> />否</label>
				<#else>
					<label><input ${disabled} name="poolPreparedStatements" type="radio" value="true" checked="checked" />是</label>
					<label><input ${disabled} name="poolPreparedStatements" type="radio" value="false"/>否</label>
				</#if>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">是否可用:</label>
			<div class="controls">
				<#if datasource.poolPreparedStatements??>
					<label><input ${disabled} name="isAble" type="radio" value="true" <#if datasource.isAble>checked="checked"</#if> />是</label>
					<label><input ${disabled} name="isAble" type="radio" value="false" <#if !datasource.isAble>checked="checked"</#if> />否</label>
				<#else>
					<label><input ${disabled} name="isAble" type="radio" value="true" checked="checked" />是</label>
					<label><input ${disabled} name="isAble" type="radio" value="false"/>否</label>
				</#if>
			</div>
		</div>


		<input type="hidden" name="version" value="${datasource.version!''}"/>
		<div class="form-actions">
			<#if edit>
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />&nbsp;
			</#if>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="goback()" />
		</div>
	</form>
</body>
</html>